package com.example.leetdemo.process;

import com.alibaba.fastjson.JSONObject;
import com.example.leetdemo.utils.DateUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.Arrays;
import java.util.Date;

public class Solution518 {

    /**
     * 跳格子+去重
     *
     * @param amount
     * @param coins
     * @return
     */
    public int change(int amount, int[] coins) {
        Arrays.sort(coins);
        int[] dp = new int[amount + 1];
        for (int i = 1; i <= amount; i++) {
            int dp_scheme = 0;
            for (int j = 0; j < coins.length; j++) {
                if (coins[j] > i) {
                    continue;
                }
                if (coins[j] == i) {
                    dp_scheme += 1;
                }
                if (coins[j] < i) {
                    dp_scheme += dp[i - coins[j]] == 0 ? 0 : dp[i - coins[j]] + 1 ;
                }
            }
            dp[i] = dp_scheme;
        }
        return dp[amount - 1];
    }

    public static void main(String[] args) {
//        Solution518 solution518 = new Solution518();
//        System.err.println(solution518.change(3, new int[] {1, 2}));
        System.err.println("test".contains("t"));

        LocalDateTime now = LocalDateTime.now();
        long overflowSeconds = DateUtils.localDateTimeToMilli(now) / 1000 % 60;
        String devTime = DateUtils.format(now.minusSeconds(overflowSeconds));
        String beginTime = DateUtils.format(now.minusSeconds(overflowSeconds).minusSeconds(60));
        System.err.println(beginTime);
        System.err.println(devTime);


        System.err.println(devTime.substring(5, 10));
        System.err.println(devTime.substring(5, 7));
        System.err.println(devTime.substring(11, 16));
        Short te = (short) 1;
        System.err.println(te.toString());
        // 输出结果
        String endTime = DateUtils.format(LocalDateTime.now().plusDays(1), "yyyy-MM-dd 00:00:00");
        System.err.println(endTime);

        System.err.println(endTime.substring(5, 7));
        System.err.println(endTime.substring(5, 10));
        System.err.println("11111");
        String time = "14:00,24:00";
        System.err.println(time.substring(0, 5));
        System.err.println(time.substring(6, 11));

        endTime = DateUtils.format(now, "yyyy-MM-dd 23:59:59");
        System.err.println(endTime);

        System.err.println(getBeginTime((short) 1, now));
        System.err.println(getBeginTime((short) 2, now));
        System.err.println(getBeginTime((short) 3, now));

        System.err.println(111111111);
        LocalDateTime month = LocalDateTime.now().with(TemporalAdjusters.firstDayOfMonth());
        System.err.println(DateUtils.format(month));
        System.err.println(BigDecimal.valueOf(Math.random() * 10000).setScale(4, RoundingMode.HALF_UP).toString());

    }


    private static String getBeginTime(Short timeType, LocalDateTime now) {
        String beginDate = "";

        if (timeType == (short) 1) {
            beginDate = DateUtils.format(now.minusDays(6), "yyyy-MM-dd 00:00:00");
        }
        if (timeType == (short) 2) {
            beginDate = DateUtils.format(now.minusDays(29), "yyyy-MM-dd 00:00:00");
        }
        if (timeType == (short) 3) {
            beginDate = DateUtils.format(now.minusMonths(11), "yyyy-MM-01 00:00:00");
        }
        return beginDate;
    }
}

